package cn.tedu.csmall.passport.service.impl;

import com.example.csmall.commons.ex.ServiceException;
import cn.tedu.csmall.passport.mapper.AdminRoleMapper;
import cn.tedu.csmall.passport.service.IAdminRoleService;
import com.example.csmall.commons.web.ServiceCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AdminRoleServiceImpl implements IAdminRoleService {

    @Autowired
    private AdminRoleMapper adminRoleMapper;

    // 根据adminId删除管理员与角色关联数据
    @Override
    public void deleteByAdminId(Long adminId) {
        log.debug("开始处理【根据ID删除管理员与角色关联数据】的业务,参数:{}", adminId);
        int rows = adminRoleMapper.deleteByAdminId(adminId);
        if (rows != 1) {
            String message = "删除管理员与角色关联数据失败，服务器忙，请稍后再试！";
            log.warn(message);
            throw new ServiceException(ServiceCode.ERR_DELETE, message);
        }
        log.debug("根据ID删除管理员与角色关联数据完成!");
    }
}
